<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

    <ui:define name="head">
        <style type="text/css">
            .col-95 {
                width: 95%;
            }

            .col-5 {
                width: 5%;
            }
        </style>
        <script language="JavaScript" type="text/JavaScript">
            //<![CDATA[
            function KeyDown() {
                if (event.keyCode == 13) {
                        event.keyCode = 9;
                }
            }

            var nextPrtId;
            function printAllVch() {
                //alert(pdtvar.toString());
                //var pkid = obj.parentNode.parentNode.parentNode.getAttribute("data-rk");
                //var rows = pdtvar.getElementsByTagName("tr");
//                for (var i=1;i<rows.length;++i)
//                    rows[i].className = 'rowClassSelected';

                //document.getElementById('printFrame').location.reload();
                if (confirm("确认开始打印吗?")){
                    //printall();
                    //printTure();

                    nextPrtId = '';
                    //while (confirm("确认开始打印吗??")){
                        getPrintRecord();
                    //}
                    //alert("====" + nextPrtId);

                    //printHidden("common/qryWaitPrtVch.xhtml");
                }
            }

            //查询
            function handleGetPrintRecordComplete(xhr, status, args) {
                if(args.validationFailed) {
                    alert("交易返回结果异常！");
                }
                else {
                    nextprtId = args.acctno;
                    //printHidden("common/qryWaitPrtVch.xhtml")
                    //document.frames["printFrame"].src = "common/qryWaitPrtVch.xhtml?id=" + nextprtId;
//                    document.getElementById('printFrame').location.reload();
//                    document.frames["printFrame"].location.reload();
                    setTimeout(function(){
                        document.frames['printFrame'].location.reload();
                    },0);
                    alert("acctno:" + args.acctno);
                }
            }

            //
            function printHidden(url) {
                var mainform = document.getElementById("printDiv");
                alert(mainform.innerHTML);
                mainform.insertAdjacentHTML("beforeEnd",
                        "<iframe name=printHiddenFrame width=20 height=20></iframe>");
                var doc = printHiddenFrame.document;
                doc.open();
                //doc.write("<body onload=\"parent.printTure()\">");
                doc.write("<body>");
                doc.write("12121221212211212121212");
                doc.write("<iframe name=printMe width=20 height=20 src=\"" +
                        url + "\"></iframe>");
                doc.write("</body>");
                alert("111");
                doc.close();
            }


            //用于设置打印参数
            function printBase() {
                factory.printing.header = "" //页眉
                factory.printing.footer = "" //页脚
                factory.printing.portrait = true //true为纵向打印，false为横向打印
                factory.printing.leftMargin = 0.5
                factory.printing.topMargin = 1.5
                factory.printing.rightMargin = 0.5
                factory.printing.bottomMargin = 1.5
            }

            function printTure()
            {
                alert("开始。。。");
                printBase();
//                document.getElementById("btnPrint").style.display = "none";//隐藏按钮
                //factory.printing.Preview();
//                factory.printing.Print(false);
                factory.printing.Print(false, 'printFrame');
//                document.getElementById("btnPrint").style.display = "inline";//显示按钮
            }

            //]]>
        </script>
    </ui:define>
    <ui:define name="content">
        <OBJECT id="factory" codeBase="smsx.cab#Version=6,6,440,20"
                height="0" width="0" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext="true">
        </OBJECT>
        <div style="margin:5px">
            <p:tabView id="tabview" dynamic="true" cache="false" style="font-weight:normal;font-style:normal">
                <p:tab title="维修资金缴款处理">
                    <h:form id="mainform">
                        <div id="qrytable">
                            <p:messages id="msgs" showDetail="false"/>
                            <p:focus for="msgsn" />
                            <p:panel style="margin-top:10px">
                                <h:panelGrid columns="2" cellspacing="5" columnClasses="col-95,col-5">
                                    <h:panelGrid columns="2" cellspacing="5">
                                        <h:outputLabel value="申请单编号:" style="font-weight: bold"/>
                                        <p:inputText required="true" size="25"
                                                     requiredMessage="申请单编号不能为空。"
                                                     id="msgsn" onkeydown="KeyDown()"
                                                     value="#{depositAction.msgSn}"/>
                                        <h:outputLabel value="交易金额:" style="font-weight: bold"/>
                                        <p:inputText id="amt" size="25"
                                                     autocomplete="false" required="true"
                                                     value="#{depositAction.txnAmt}"
                                                     requiredMessage="交易金额不能为空。"
                                                     validatorMessage="请输入正确的金额格式。">
                                            <f:convertNumber for="amt" maxFractionDigits="2" maxIntegerDigits="13"
                                                             pattern="###,###,###,###,##0.00"/>
                                        </p:inputText>
                                    </h:panelGrid>
                                    <h:panelGrid id="buttons">
                                        <p:commandButton style="width:110px;" value="查询缴款信息"
                                                         disabled="#{depositAction.checkPassed}"
                                                         rendered="#{!depositAction.confirmed}"
                                                         action="#{depositAction.onQuery}"
                                                         update="pdt,msgs,buttons">
                                        </p:commandButton>
                                        <p:commandButton style="width:110px;" value="确认缴款"
                                                         rendered="#{depositAction.checkPassed}"
                                                         disabled="#{depositAction.confirmed}"
                                                         action="#{depositAction.onConfirm}"
                                                         update="pdt,msgs,buttons">
                                        </p:commandButton>
                                        <p:commandButton style="width:110px;" value="凭证打印"
                                                         rendered="#{depositAction.confirmed}"
                                                         action="#{depositAction.onVchPrt}"
                                                         update="pdt,msgs,buttons">
                                        </p:commandButton>
                                    </h:panelGrid>
                                </h:panelGrid>
                            </p:panel>
                            <p:ajaxStatus style="height:18px;text-align:center">
                                <f:facet name="start">
                                    <h:graphicImage value="/images/ajaxloadingbar.gif"/>
                                </f:facet>
                                <f:facet name="complete">
                                    <h:outputText value=""/>
                                </f:facet>
                            </p:ajaxStatus>
                            <p:menubar style="margin-bottom:3px;">
                                <p:menuitem type="push" value="打印所选记录凭证" icon="ui-icon ui-icon-checked"
                                            action="#{depositAction.onPrintAll}" ajax="false" />
                                <p:menuitem type="push" value="打印列表中全部凭证" icon="ui-icon ui-icon-print"
                                            process="@this"
                                            onclick="printAllVch();"
                                            update="msgs, pdt"
                                            ajax="true"/>
                            </p:menubar>
                            <p:dataTable id="pdt" dynamic="true" style="width:100%;margin-bottom:8px;"
                                         value="#{depositAction.subMsgList}" var="record"
                                         rowKey="#{record.pkid}"
                                         selection="#{depositAction.selectedRecords}"
                                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} 【总笔数:#{depositAction.totalCount}】"
                                         paginator="true" rows="15" paginatorPosition="bottom"
                                         rowsPerPageTemplate="100,50,30,15,5"
                                         widgetVar="pdtvar"
                                         emptyMessage="数据记录为空...">
                                <p:column selectionMode="multiple" style="width:18px"/>
                                <p:column headerText="业主姓名" style="text-align: center">
                                    <h:outputText value="#{record.infoName}"/>
                                </p:column>
                                <p:column headerText="金额">
                                    <h:outputText value="#{record.txnAmt1}" style="float: right">
                                        <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="资金帐号" style="text-align: center">
                                    <h:outputText value="#{record.fundActno1}"/>
                                </p:column>
                                <p:column headerText="住宅地址" style="text-align: center">
                                    <h:outputText value="#{record.infoAddr}"/>
                                </p:column>
                                <p:column headerText="建筑面积" style="text-align: center">
                                    <h:outputText value="#{record.builderArea}"/>
                                </p:column>
                                <p:column headerText="住宅类型" style="text-align: center">
                                    <h:outputText value="#{record.houseDepType}"/>
                                </p:column>
                                <p:column headerText="工程造价|缴存比例" style="text-align: center">
                                    <h:outputText value="#{record.depStandard2}"/>
                                </p:column>
                                <p:column headerText="电话" style="text-align: center">
                                    <h:outputText value="#{record.houseCustPhone}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                        <p:remoteCommand name="printall" id="printall" async="true"
                                         actionListener="#{depositAction.onPrintAll}"
                                         update="msgs" process="@none"/>
                        <p:remoteCommand name="getPrintRecord" id="getPrintRecord" async="true"
                                         actionListener="#{depositAction.searchFirstOneRecordForPrint}"
                                         update="msgs" process="@none"
                                         oncomplete="handleGetPrintRecordComplete(xhr, status, args)"/>
                        <div id="printDiv">

                        </div>
                        <iframe id="printFrame" width="100%" height="200" src="common/qryWaitPrtVch.xhtml"></iframe>
                    </h:form>
                </p:tab>
                <p:tab title="已打印票据清单">
                    <h:form>
                    </h:form>
                </p:tab>

            </p:tabView>
        </div>
    </ui:define>
</ui:composition>